﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Web.Mvc;
using AFT.Parking.Entity.Enums;
using AFT.Parking.Entity.Parkings;
using AFT.Parking.WebSite.Filter;
using AFT.Parking.WebSite.Models;
using Newtonsoft.Json;
using Model = AFT.Parking.Entity;
using AFT.Parking.Foundation.Extensions;
using AFT.Parking.Bizlogic.Parkings;
using System.Linq.Expressions;
using AFT.Parking.Entity.ArgumentEntity;
using AFT.Parking.WebSite.Common;
using System.Linq;
using AFT.Parking.Foundation.Calculate;

namespace AFT.Parking.WebSite.Controllers
{
    [AdminOnly]
    public class ParkingAreasController : BaseController
    {
        #region Fields
        private readonly ParkingBiz _parkingBiz;
        #endregion

        #region Ctor
        public ParkingAreasController()
        {
            _parkingBiz = new ParkingBiz();
        }
        #endregion

        #region Parking Manage
        public ActionResult AddParking()
        {
            return View(new Model.Parking() { IsEnable = true });
        }
        [HttpPost]
        public ActionResult AddParking(Model.Parking parking)
        {
            string msg = string.Empty;
            string icon = "error";

            if (parking.Name.IsNullOrEmpty())
                msg = "停车场名称不能为空；";
            if (parking.LocationX <= 0 || parking.LocationY <= 0)
                msg += "经纬度不能为空；";
            if (parking.Address.IsNullOrEmpty())
                msg += "停车场地址不能为空。";
            if (msg.Length == 0)
            {
                parking.CreatedOn = DateTime.Now;
                parking.CreatedBy = Customer.Id;
                if (_parkingBiz.AddParkings(parking))
                {
                    icon = "success";
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，存在相同的停车场信息。";
            }
            ViewBag.Message = msg;
            ViewBag.Icon = icon;
            return View(parking);
        }

        public ActionResult EditeParking(int id)
        {
            var parking = _parkingBiz.GetSingle(id);
            if (parking == null)
                return Redirect("/parkingareas/parkings");
            return View(parking);
        }
        [HttpPost]
        public ActionResult EditeParking(Model.Parking parking)
        {
            string msg = string.Empty;
            string icon = "error";

            if (parking.Name.IsNullOrEmpty())
                msg = "停车场名称不能为空；";
            if (parking.LocationX <= 0 || parking.LocationY <= 0)
                msg += "经纬度不能为空；";
            if (parking.Address.IsNullOrEmpty())
                msg += "停车场地址不能为空。";
            if (msg.Length == 0)
            {
                if (_parkingBiz.EditeParking(parking))
                {
                    icon = "success";
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，存在相同的停车场信息。";
            }
            ViewBag.Message = msg;
            ViewBag.Icon = icon;
            return View(parking);
        }
        public ActionResult Parkings(string name, string agents, int page = 1)
        {
            Expression<Func<Model.Parking, bool>> exp = u => true;
            if (!name.IsNullOrEmpty())
                exp = exp.And(u => u.Name.ToLower().Contains(name));
            if (!agents.IsNullOrEmpty())
                exp = exp.And(u => u.Agents.ToLower().Contains(agents));
            var param = new PaginationParam<Model.Parking>()
            {
                PageIndex = page,
                PageSize = 20,
                Expression = exp,
                OrderByList = new List<OrderBy<Model.Parking>>() { new OrderBy<Model.Parking> { Sort = false, exp = u => u.Id } }
            };
            return View(_parkingBiz.GetList(param));
        }
        #endregion

        #region ParkingAres Manage
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">parking.id</param>
        /// <returns></returns>
        public ActionResult AddAreas(int id)
        {
            var parking = _parkingBiz.GetSingle(id);
            if (parking == null)
                return Redirect("/parkingAreas/parkings");
            ViewBag.ParkingName = parking.Name;
            return View(new Model.ParkingArea() { IsEnable = true, ImgUrl = ConstFields.DefaultImage, ParkingId = id });
        }
        [HttpPost]
        public ActionResult AddAreas(Model.ParkingArea parkingArea)
        {
            var parking = _parkingBiz.GetSingle(parkingArea.ParkingId);
            if (parking == null)
                return Redirect("/parkingAreas/parkings");

            string msg = string.Empty;
            string icon = "error";

            if (parkingArea.Name.IsNullOrEmpty())
                msg = "区域名称不能为空；";
            if (parkingArea.ImgUrl.IsNullOrEmpty())
                msg += "图片不能为空。";
            if (msg.Length == 0)
            {
                parkingArea.ImgUrl = FileHelper.Save("Areas", parkingArea.ImgUrl);
                if (_parkingBiz.AddParkingArea(parkingArea))
                {
                    icon = "success";
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，同一停车场存在相同的区域信息。";
            }
            ViewBag.ParkingName = parking.Name;
            ViewBag.Message = msg;
            ViewBag.Icon = icon;
            return View(parkingArea);
        }

        public ActionResult EditeAreas(int id)
        {
            var parkingArea = _parkingBiz.GetParkingArea(id);
            if (parkingArea == null)
                return Redirect("/parkingAreas/parkings");
            ViewBag.ParkingName = _parkingBiz.GetSingle(parkingArea.ParkingId).Name;
            return View(parkingArea);
        }
        [HttpPost]
        public ActionResult EditeAreas(Model.ParkingArea parkingArea)
        {
            var areas = _parkingBiz.GetParkingArea(parkingArea.Id);
            if (areas == null)
                return Redirect("/parkingAreas/parkings");

            string msg = string.Empty;
            string icon = "error";

            if (parkingArea.Name.IsNullOrEmpty())
                msg = "区域名称不能为空；";
            if (parkingArea.ImgUrl.IsNullOrEmpty())
                msg += "图片不能为空。";
            if (msg.Length == 0)
            {
                parkingArea.ImgUrl = FileHelper.Save("Areas", parkingArea.ImgUrl);
                if (_parkingBiz.EditeParkingArea(parkingArea))
                {
                    icon = "success";
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，同一停车场存在相同的区域信息";
            }
            ViewBag.ParkingName = _parkingBiz.GetSingle(parkingArea.ParkingId).Name;
            ViewBag.Message = msg;
            ViewBag.Icon = icon;
            return View(parkingArea);
        }

        public ActionResult Areas(string name, int parkingId = 0, int page = 1)
        {
            Expression<Func<Model.ParkingArea, bool>> exp = u => true;
            if (!name.IsNullOrEmpty())
                exp = exp.And(u => u.Name.ToLower().Contains(name.ToLower()));
            if (parkingId > 0)
            {
                exp = exp.And(u => u.ParkingId == parkingId);
                ViewBag.ParkingName = _parkingBiz.GetSingle(parkingId).Name;
            }
            var param = new PaginationParam<Model.ParkingArea>()
            {
                PageIndex = page,
                PageSize = 20,
                Expression = exp,
                OrderByList = new List<OrderBy<Model.ParkingArea>>() { new OrderBy<Model.ParkingArea>() { Sort = false, exp = u => u.Id } }
            };
            ViewBag.ParkingId = parkingId;
            return View(_parkingBiz.GetAreasList(param));
        }
        /// <summary>
        /// 计算坐标点在图上的位置
        /// </summary>
        /// <param name="id">parkingarea.id</param>
        /// <returns></returns>
        public ActionResult CheckLocations(int id)
        {
            string imgSrc = ConstFields.DefaultImage;
            var parkingArea = _parkingBiz.GetParkingArea(id);
            if (parkingArea != null && !parkingArea.ImgUrl.IsNullOrEmpty())
            {
                var locations = _parkingBiz.GetListByParkingAreaId(id);
                string ImgUrl = parkingArea.ImgUrl;
                bool isOriginalImg = true;
                foreach (var item in locations)
                {
                    if (!item.AccessTo.IsNullOrEmpty())
                    {
                        var accessTo = JsonConvert.DeserializeObject<List<AccessToEx>>(item.AccessTo);

                        foreach (var a in accessTo)
                        {
                            var toLocation = _parkingBiz.GetParkingLocation(a.Id);
                            string returnImg = Common.FileHelper.DrawDashOrArrow(ImgUrl, (int)item.LocationX, (int)item.LocationY,
                                (int)toLocation.LocationX, (int)toLocation.LocationY, false, true);
                            if (isOriginalImg)
                            {
                                isOriginalImg = false;
                            }
                            else
                            {
                                if (System.IO.File.Exists(Server.MapPath(string.Format(ImgUrl, ""))))
                                    System.IO.File.Delete(Server.MapPath(string.Format(ImgUrl, "")));
                            }
                            ImgUrl = string.Format(returnImg, "");
                        }
                    }
                }
                imgSrc = ImgUrl;
            }
            ViewBag.Img = imgSrc;
            return View();
        }

        #endregion

        #region ParkingLocation Manage

        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">parkingArea.id</param>
        /// <returns></returns>
        public ActionResult AddLocation(int id)
        {
            var parkingArea = _parkingBiz.GetParkingArea(id);
            if (parkingArea == null)
                return Redirect("/parkingAreas/Areas");

            ViewData["AllLocation"] = new SelectList(_parkingBiz.SameAreasLocations(id), "id", "name");// LocationsToList();
            ViewData["AccessTo"] = new List<SelectListItem>();// LocationsToList(null);

            var parking = _parkingBiz.GetSingle(parkingArea.ParkingId);
            ViewBag.ParkingName = parking.Name;
            ViewBag.ParkingAreaName = parkingArea.Name;
            return View(new Model.ParkingLocation() { ParkingAreaId = id, IsFork = false, IsEnable = true });
        }
        [HttpPost]
        public ActionResult AddLocation(Model.ParkingLocation parkingLocation, List<int> AccessTo)
        {
            var parkingArea = _parkingBiz.GetParkingArea(parkingLocation.ParkingAreaId);
            if (parkingArea == null)
                return Redirect("/parkingAreas/Areas");
            if (AccessTo == null || AccessTo.Count == 0)
            {
                AccessTo = new List<int>();
                AccessTo.Add(0);
            }
            var source = _parkingBiz.SameAreasLocations(parkingLocation.ParkingAreaId);
            var accessToList = source.Where(u => AccessTo.Contains(u.Id));
            ViewData["AllLocation"] = new SelectList(source.Where(u => !AccessTo.Contains(u.Id)), "id", "name");// LocationsToList();
            ViewData["AccessTo"] = new SelectList(accessToList, "id", "name");// LocationsToList(null);

            string msg = string.Empty;
            string icon = "error";

            if (parkingArea.Name.IsNullOrEmpty())
                msg = "立柱名称不能为空；";
            if (parkingLocation.LocationX <= 0 || parkingLocation.LocationY < 0)
                msg += "坐标不能为空。";

            if (msg.Length == 0)
            {
                if (accessToList.Any())
                {
                    var accessTos = new List<AccessToEx>();
                    AccessToEx accessTo;
                    foreach (var item in accessToList)
                    {
                        accessTo = new AccessToEx()
                        {
                            Id = item.Id,
                            Weight = Distance.GetDistanceOfPoint(parkingLocation.LocationX, parkingLocation.LocationY, item.LocationX, item.LocationY)
                        };
                        accessTos.Add(accessTo);
                    }
                    parkingLocation.AccessTo = JsonConvert.SerializeObject(accessTos);
                }
                else
                    parkingLocation.AccessTo = string.Empty;
                if (_parkingBiz.AddParkingLocation(parkingLocation))
                {
                    icon = "success";
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，同一停车区存在相同的立柱信息。";
            }
            var parking = _parkingBiz.GetSingle(parkingArea.ParkingId);
            ViewBag.ParkingName = parking.Name;
            ViewBag.ParkingAreaName = parkingArea.Name;
            ViewBag.Message = msg;
            ViewBag.Icon = icon;
            return View(parkingLocation);
        }

        public ActionResult EditeLocation(int id)
        {
            var location = _parkingBiz.GetParkingLocation(id);
            if (location == null)
                return Redirect("/parkingAreas/Areas");
            var parkingArea = _parkingBiz.GetParkingArea(location.ParkingAreaId);
            if (parkingArea == null)
                return Redirect("/parkingAreas/Areas");
            var parking = _parkingBiz.GetSingle(parkingArea.ParkingId);

            var AccessTo = new List<int>();
            var s = JsonConvert.DeserializeObject<List<AccessToEx>>(location.AccessTo);
            if (s != null && s.Any())
            {
                AccessTo.AddRange(s.Select(u => u.Id));
            }
            else
                AccessTo.Add(0);

            var source = _parkingBiz.SameAreasLocations(location.ParkingAreaId, id);
            var accessToList = source.Where(u => AccessTo.Contains(u.Id));
            ViewData["AllLocation"] = new SelectList(source.Where(u => !AccessTo.Contains(u.Id)), "id", "name");// LocationsToList();
            ViewData["AccessTo"] = new SelectList(accessToList, "id", "name");// LocationsToList(null);

            ViewBag.ParkingName = parking.Name;
            ViewBag.ParkingAreaName = parkingArea.Name;
            return View(location);
        }
        [HttpPost]
        public ActionResult EditeLocation(Model.ParkingLocation parkingLocation, List<int> AccessTo)
        {
            var parkingArea = _parkingBiz.GetParkingArea(parkingLocation.ParkingAreaId);
            if (parkingArea == null)
                return Redirect("/parkingAreas/Areas");
            if (AccessTo == null || AccessTo.Count == 0)
            {
                AccessTo = new List<int>();
                AccessTo.Add(0);
            }
            var source = _parkingBiz.SameAreasLocations(parkingLocation.ParkingAreaId);
            var accessToList = source.Where(u => AccessTo.Contains(u.Id));
            ViewData["AllLocation"] = new SelectList(source.Where(u => !AccessTo.Contains(u.Id)), "id", "name");// LocationsToList();
            ViewData["AccessTo"] = new SelectList(accessToList, "id", "name");// LocationsToList(null);

            string msg = string.Empty;
            string icon = "error";

            if (parkingArea.Name.IsNullOrEmpty())
                msg = "立柱名称不能为空；";
            if (parkingLocation.LocationX <= 0 || parkingLocation.LocationY < 0)
                msg += "坐标不能为空。";

            if (msg.Length == 0)
            {
                if (accessToList.Any())
                {
                    var accessTos = new List<AccessToEx>();
                    AccessToEx accessTo;
                    foreach (var item in accessToList)
                    {
                        accessTo = new AccessToEx()
                        {
                            Id = item.Id,
                            Weight = Distance.GetDistanceOfPoint(parkingLocation.LocationX, parkingLocation.LocationY, item.LocationX, item.LocationY)
                        };
                        accessTos.Add(accessTo);
                    }
                    parkingLocation.AccessTo = JsonConvert.SerializeObject(accessTos);
                }
                else
                    parkingLocation.AccessTo = string.Empty;
                if (_parkingBiz.EditeParkingLocation(parkingLocation))
                {
                    icon = "success";
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，同一停车区存在相同的立柱信息。";
            }
            var parking = _parkingBiz.GetSingle(parkingArea.ParkingId);
            ViewBag.ParkingName = parking.Name;
            ViewBag.ParkingAreaName = parkingArea.Name;
            ViewBag.Message = msg;
            ViewBag.Icon = icon;
            return View(parkingLocation);
        }

        public ActionResult Locations(string name, int parkingAreaId = 0, int page = 1, int bindId = -1)
        {
            Expression<Func<Model.ParkingLocation, bool>> exp = u => true;
            if (!name.IsNullOrEmpty())
                exp = exp.And(u => u.Name.Contains(name));
            var parkingArea = _parkingBiz.GetParkingArea(parkingAreaId);
            if (parkingAreaId != 0 && parkingArea != null)
            {
                exp = exp.And(u => u.ParkingAreaId == parkingAreaId);
                ViewBag.ParkingAreaName = parkingArea.Name;
                ViewBag.ParkingAreaId = parkingAreaId;
            }
            Expression<Func<Model.ScanCodeAndLocation, bool>> relationExp = u => u.LocationType == (int)Model.Enums.LocationTypes.停车区;
            var relationIds = _parkingBiz.GetScanCodeAndLocations(relationExp).Select(u => u.LocationId);
            if (bindId == 0)//未绑定
            {
                exp = exp.And(u => !relationIds.Contains(u.Id));
            }
            else if (bindId == 1)//绑定
            {
                exp = exp.And(u => relationIds.Contains(u.Id));
            }
            var p = new PaginationParam<Model.ParkingLocation>()
            {
                Expression = exp,
                PageSize = 20,
                PageIndex = page,
                OrderByList =
                    new List<OrderBy<Model.ParkingLocation>>()
                    {
                        new OrderBy<Model.ParkingLocation>() {Sort = false, exp = u => u.Id}
                    }
            };
            ViewData["bindId"] = typeof(Model.Enums.LocationBindStatus).EnumToList(bindId, true);
            ViewBag.parkingAreaId = parkingAreaId;
            ViewBag.ScanCodeCount = _parkingBiz.GetSurplusScanCodeCount();
            return View(_parkingBiz.GetLocationsList(p));
        }

        public ActionResult DeleteLocation(int id)
        {
            string result = string.Empty;
            _parkingBiz.DeleteScanCodeAndLocation(u => u.LocationId == id && u.LocationType == (int)LocationTypes.停车区);
            _parkingBiz.DeleteParkingLocation(id);
            return Content("1");
        }

        public ActionResult UpdateCacheLocations()
        {
            var data = new Parking.Bizlogic.Parkings.ParkingBiz().InitNodes();
            Parking.Foundation.Caching.HttpCaches.SetCache(Parking.WebSite.Common.ConstFields.InitParkLocationsCacheKey, data);
            return Content("");
        }


        #endregion

        #region ScanCode Manage

        public ActionResult RecoverScanCode(int id)
        {
            string ticket = string.Empty;
            var paringLocation = _parkingBiz.GetParkingLocation(id);
            if (paringLocation != null)
            {
                int locationType = (int)Model.Enums.LocationTypes.停车区;
                Expression<Func<Model.ScanCodeAndLocation, bool>> exp = u => u.LocationId == id && u.LocationType == locationType;
                var relation = _parkingBiz.GetScancodeAndLocation(exp);
                if (relation == null)
                {
                    var scanCode = _parkingBiz.GetScanCodeNotUse();
                    if (scanCode != null)
                    {
                        var scanCodeAndLocation = new Model.ScanCodeAndLocation()
                        {
                            ScanCodeId = scanCode.Id,
                            LocationId = id,
                            LocationType = locationType
                        };
                        _parkingBiz.AddScanCodeAndLocation(scanCodeAndLocation);
                        ticket = scanCode.Ticket;
                    }
                }
                else
                {
                    _parkingBiz.DeleteScanCodeAndLocation(exp);
                    ticket = "haha";
                }
            }
            return Content(ticket);
        }

        public ActionResult BindScanCode(string ids, string t)
        {
            if (ids.Trim(',').IsNullOrEmpty())
                return Content("");
            string[] arrIds = ids.Trim(',').Split(',');
            int[] arr = Array.ConvertAll<string, int>(arrIds, u => int.Parse(u));
            string result = string.Empty;

            foreach (var item in arr)
            {
                // int locationId = Convert.ToInt32(item);
                var parkingLocationAndScanCode =
                    _parkingBiz.GetScancodeAndLocation(
                        u => u.LocationId == item && u.LocationType == (int)LocationTypes.停车区);

                if (t.Equals("bind") && parkingLocationAndScanCode == null)
                {
                    var scanCode = _parkingBiz.GetScanCodeNotUse();

                    if (scanCode != null)
                    {
                        var model = new Model.ScanCodeAndLocation()
                        {
                            LineImg = string.Empty,
                            LocationType = (int)LocationTypes.停车区,
                            LocationId = item,
                            ScanCodeId = scanCode.Id,
                            ShowTxt = string.Empty
                        };
                        _parkingBiz.AddScanCodeAndLocation(model);
                    }
                    var scanCodeIds =
                        _parkingBiz.GetScanCodeAndLocations(
                            u => arr.Contains(u.LocationId) && u.LocationType == (int)LocationTypes.停车区).Select(u => u.ScanCodeId).ToList();
                    if (scanCodeIds.Count > 0)
                    {
                        var tickets = _parkingBiz.GetScanCodes(u => scanCodeIds.Contains(u.Id));
                        if (tickets.Count > 0)
                        {
                            result = string.Join(",", tickets.Select(u => u.Ticket).ToList());
                        }
                    }
                }
                else
                {
                    _parkingBiz.DeleteScanCodeAndLocation(u => u.LocationId == item && u.LocationType == (int)LocationTypes.停车区);
                    result = "success";
                }
            }

            return Content(result);
        }

        /// <summary>
        /// id : locationId
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [AdminOnly(false)]
        public ActionResult PrintScanCode(int id)
        {
            var locationEx = _parkingBiz.GetLocationExById(id);
            return View(locationEx);
        }
        [AdminOnly(false)]
        public ActionResult Scancodes(int parkingAreaId = 0, int page = 1)
        {
            Expression<Func<Model.ScanCodeAndLocation, bool>> relationExp = u => u.LocationType == (int)Model.Enums.LocationTypes.停车区;
            var relationIds = _parkingBiz.GetScanCodeAndLocations(relationExp).Select(u => u.LocationId).ToArray();
            var p = new PaginationParam<Model.ParkingLocation>()
            {
                Expression = u => relationIds.Contains(u.Id),
                PageSize = 20,
                PageIndex = page,
                OrderByList =
                    new List<OrderBy<Model.ParkingLocation>>()
                    {
                        new OrderBy<Model.ParkingLocation>() {Sort = false, exp = u => u.Id}
                    }
            };
            ViewBag.parkingAreaId = parkingAreaId;
            ViewBag.ScanCodeCount = _parkingBiz.GetSurplusScanCodeCount();
            return View(_parkingBiz.GetLocationsList(p));
        }

        #endregion

        #region Print scancode by printer
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id">id:ParkingLocationId</param>
        /// <returns></returns>
        public ActionResult ParkingPillars(int id)
        {
            return View();
        }

        #endregion
        public ActionResult FileUpLoadFile(string folderName)
        {
            var result = FileHelper.Upload(folderName);
            return Content(JsonConvert.SerializeObject(result));
        }

        #region Lift Manage

        public ActionResult Lifts(string name, int parkingId = 0, int page = 1)
        {
            Expression<Func<Model.ParkingLift, bool>> exp = u => true;
            var param = new PaginationParam<Model.ParkingLift>
            {
                PageIndex = page,
                PageSize = 20,
                Expression = exp,
                OrderByList = new List<OrderBy<Model.ParkingLift>> { new OrderBy<Model.ParkingLift> { Sort = false, exp = u => u.Id } }
            };
            ViewBag.ParkingId = parkingId;
            var result = _parkingBiz.GetLiftList(param);
            return View(result);
        }

        public ActionResult AddLift(int id)
        {
            var parking = _parkingBiz.GetSingle(id);
            if (parking == null)
                return Redirect("/parkingAreas/parkings");
            ViewBag.ParkingName = parking.Name;
            return View(new Model.ParkingLift { ParkingId = id });
        }

        [HttpPost]
        public ActionResult AddLift(Lift parkingLift)
        {
            var parking = _parkingBiz.GetSingle(parkingLift.ParkingId);
            if (parking == null)
                return Redirect("/parkingAreas/parkings");


            string msg = string.Empty;

            if (parkingLift.Name.IsNullOrEmpty())
                msg = "电梯名称不能为空；";
            if (parkingLift.CrossTo == null)
                msg += "关联电梯不能为空；";

            var lift = new Model.ParkingLift
            {
                Id = parkingLift.Id,
                ParkingId = parkingLift.ParkingId,
                Name = parkingLift.Name,
                CrossTo = JsonConvert.SerializeObject(_parkingBiz.GetLiftAcrossTos(parkingLift.CrossTo))
            };
            if (msg.Length == 0)
            {
                if (_parkingBiz.AddLift(lift))
                {
                    msg = "保存成功。";
                }
                else
                    msg = "保存失败，同一停车场存在相同的区域信息。";
            }
            ViewBag.Message = msg;
            return Json(msg);
        }

        public ActionResult GetIsLifts(int id)
        {
            var locations = _parkingBiz.IsLiftList(id).Select(p => new { p.Id, p.Name });
            return Json(locations, "application/json", JsonRequestBehavior.AllowGet);
        }

        public ActionResult DelLift(int id)
        {
            _parkingBiz.DelLift(id);
            return Content("删除成功");
        }
        #endregion
    }
}